package cn.wuqingna.legendgem.script


import me.clip.placeholderapi.PlaceholderAPI
import org.bukkit.entity.Player

object PlaceholderScript: Script {
    override val key: String
        get() = "papi"

    override fun eval(player: Player, args: String, cache: MutableMap<String, String>): String {
        val str = args.split("papi:")[1].replace("}", "")
        try {
            return if (args.contains("def")){
                str.split("def:")[1]
            } else {
                PlaceholderAPI.setPlaceholders(player, str)
            }
        } catch (e: Exception) {
            error("papi 语句错误 $args")
        }
    }
}